﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL.DataSourceImplementation.HelpersDAO
{
    public abstract class BaseDAO<T> where T:class
    {
        public virtual List<T> PageResult(List<T> results, int pageIndex, int pageSize, int total)
        {
            int num = (int)Math.Ceiling((double)(((double)total) / ((double)pageSize)));
            if (num < 1)
            {
                num = 1;
            }
            pageIndex = (pageIndex > num) ? num : pageIndex;
            int count = (pageIndex - 1) * pageSize;
            return results.Skip<T>(count).Take<T>(pageSize).ToList();
        }
    }
}
